import { defineStore } from "pinia";
import {proCategorylist ,proCategorybrandlist} from '../api/class'
type State = {
    classList:[],
    resClass:number,
    subBrand:ClassList[]
}
export const useClass = defineStore(
    'class-stores',
    {
        state: ():State =>{
            return {
                // 分类数据
                classList:[],
                // 保存当前点击的分类
                resClass:0,
                // 分类的子品牌
                subBrand:[]
            }
        },
        getters:{

        },
        actions:{
            // 获取分类数据
            async feachProCategorylist(){
                let result = await proCategorylist()
                this.classList = result.data
            },
            // 获取分类下面的所有品牌
            async feachproCategorybrandlist(index:number){
                // 记录当前的页面
                this.resClass = index
                let result = await proCategorybrandlist(this.classList[index])
                this.subBrand = result.data
            }
        }
    }
)